package com.demo.controller;

import com.demo.entity.Student;
import com.demo.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class StudentController {

    @Autowired
    private StudentService studentService;

    @PostMapping(value = "/findById/{id}")
    public Student findById(@PathVariable Integer id) {
        return studentService.findById(id);
    }

    @PostMapping(value = "/add")
    public String add(@RequestBody  Student student) {
        return studentService.add(student);
    }
    @PostMapping(value = "/update")
    public String update(@RequestBody  Student student) {
        return studentService.update(student);
    }
    @DeleteMapping(value = "/delete/{id}")
    public String delete(@PathVariable Integer id) {
        return studentService.delete(id);
    }
}